#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;

int arry[10] = {0};

typedef struct node{
    int pointNum;
    struct node *next;
}Node;

typedef struct graph{
    int pointCount;
    int lineCount;
    Node *arr[10];
}Graph;

Node* newNode(int num, int is, Node *next );
Graph* link(Graph *graph,int num);

Graph* init(int num){
    int i;
    Graph *graph = (Graph *)malloc(sizeof(Graph));
    graph->pointCount=num;
    graph->lineCount=num-1;

    for(i=0;i<num;i++){

        graph->arr[i] = newNode(i+1,0,NULL);
    }
    
    return link(graph,num);
}

Graph* link(Graph *graph,int num){
    int i,j;
    Node *node;
    for(i=0;i<num;i++){
        node = graph->arr[i];
        for(j=0;j<num;j++){
            if(i != j){
                node->next = newNode(graph->arr[j]->pointNum,0,NULL);
                node = node->next;
            }
        }
    }
    return graph;
}

Node* newNode(int num, int is, Node *next ){
    Node *node = (Node *)malloc(sizeof(Node));
    node->pointNum = num;
    node->next = next;
    return node;
}

void dfsSearch(int *tag, Graph *graph, int layer, Node *node, int num)
{
    arry[layer] = node->pointNum;

    if(num == layer){
        cout << endl;
        for(int i=0; i<= layer; i++){
            printf("%d \t",arry[i]);
        }
        printf("----666666666666666666666----\n");
        return;
    }

    Node *p = node->next;

    // while(p){
    //     if(arry[p->pointNum] == 0){
    //         arry[p->pointNum] = 1;
    //         dfs()
    //     }
    // }

    // cout << "index:" << node->pointNum << "\t\t";

    while(p)
    {
        if(tag[p->pointNum] == 0)
        {
            tag[p->pointNum] = 1;
            dfsSearch(tag, graph, layer + 1, graph->arr[p->pointNum-1], num);
            tag[p->pointNum] = 0;
        }
        p = p->next;
    }

    // cout << '\n';

}

int graphEcho(int num, Graph *graph)
{
    for (size_t i = 0; i < num; i++)
    {
        auto p = graph->arr[i]->next;
        cout << "index:" << i << "\t";
        while (p)
        {
            cout << p->pointNum << "\t";
            p = p->next;
        }
        cout << endl;
    }
}

int main(int argc, char const *argv[])
{

    int i;
    int num = 0;
    int tag[16]= {0};
    Graph *graph;
    scanf("%d", &num);
    graph = init(num);

    Node *node;
    
    for(i = 0; i < num; i++){
        node = graph->arr[i]; 
        tag[node->pointNum]=1; 
        dfsSearch(tag, graph, 0, node, num -1);  
        tag[node->pointNum]=0; 
    }
    /* code */
    return 0;
}
